local skel = fk.CreateSkill {
  name = "emo__fengao",
}

Fk:loadTranslationTable{
  ["emo__fengao"] = "焚稿",
  [":emo__fengao"] = "每当你使用或打出的♠牌结算后，可令一名角色选一项：1.交给你一张<font color='red'>♥</font>牌；2.受到你造成的一点火焰伤害。",

  ["#emo__fengao-choose"] = "焚稿：令一名角色选择交给你<font color='red'>♥</font>牌，或受火焰伤害",
  ["#emo__fengao-give"] = "焚稿：交给 %src 一张<font color='red'>♥</font>牌，或受1点火焰伤害",

  ["$emo__fengao1"] = "大胆！雕虫小技竟敢班门弄斧",
}

local can_trigger = function (self, event, target, player, data)
  return target == player and player:hasSkill(skel.name) and data.card.suit == Card.Spade
end

local on_cost = function (self, event, target, player, data)
  local tos = player.room:askToChoosePlayers(player, {
    targets = player.room.alive_players, min_num = 1, max_num = 1, skill_name = skel.name, prompt = "#emo__fengao-choose",
  })
  if #tos > 0 then
    event:setCostData(self, {tos = tos} )
    return true
  end
end

local on_use = function (self, event, _, player, data)
  local room = player.room
  local to = event:getCostData(self).tos[1]
  local cid
  if not to:isNude() then
    cid = room:askToCards(to, {
      min_num = 1, max_num = 1, pattern = ".|.|heart", skill_name = skel.name, cancelable = true, prompt = "#emo__fengao-give:"..player.id,
    })[1]
  end
  if cid then
    room:obtainCard(player, cid, true, fk.ReasonGive, to, skel.name)
  else
    room:damage { from = player, to = to, damage = 1, skillName = skel.name, damageType = fk.FireDamage }
  end
end

skel:addEffect(fk.CardUseFinished, {
  anim_type = "offensive",
  can_trigger = can_trigger,
  on_cost = on_cost,
  on_use = on_use,
})

skel:addEffect(fk.CardRespondFinished, {
  anim_type = "offensive",
  can_trigger = can_trigger,
  on_cost = on_cost,
  on_use = on_use,
})

return skel
